# 作者：一只牛吗
# 2025 年02月 01日 03时 23分 28秒
# 1278599690@qq.com
# 这是没有私有属性的类
class Woman:
    def __init__(self, name, age):
        self.__name = name
        self.__age = age

    def __str__(self):
        return f"My name is {self.__name} and I am {self.__age} years old."


# 这是有私有属性的类
class Man:
    def __init__(self, name, age, salary):
        self.__name = name
        self.__age = age
        self.__salary = salary

    def __secret(self):
        print(f'My secret is my salary is {self.__salary}')

    def __str__(self):
        return f"My name is {self.__name} and I am {self.__age} years old. My salary is {self.__salary}."

    def girl_friend(self):
        self.__secret()


if __name__ == '__main__':
    xiaohong = Woman("Xiaohong", 25)
    print(xiaohong)  # My name is Xiaohong and I am 25 years old.
    lilei = Man("Lilei", 24, 50000)
    # print(lilei.__salary)
    # print(lilei)  # My name is Lilei and I am 24 years old. My salary is 50000.
    # lilei.secret()  # My secret is my salary is 50000
    lilei.girl_friend()  # My secret is my salary is 50000
    print(lilei._Man__salary)  # 可以通过_类名__属性名的方式访问私有属性，但很鸡肋完全没有必要
